<html>

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>修改密码</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/sm.css">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/sm-extend.css">
    <link rel="stylesheet" type="text/css" href="${staticpath}/front/dist/css/base.css">
    <style>
        .password-card .list-block{border-bottom: 2px solid #eee;}
        .password-card .item-content .item-title{font-size: 16px;!important; }
        .password-card .item-content .item-input input{font-size: 12px;!important; }
        .list-block .item-title.label{width: 4.5rem;}
        .saveBtn{ width: 80%;  margin: 40px auto 0;}
        .saveBtn .button.button-fill{ border-radius:4px;  background:#00b0ec;  height: 40px;  line-height: 40px;  font-size:16px;}
    </style>
</head>

<body>
<div class="page-group">
    <div class="page">
        <!--头部部分 !-->
        <header class="bar bar-nav">
            <a class="icon icon-left pull-left back" href="#">返回</a>
            <h1 class="title">修改密码</h1>
        </header>
        <div class="content set-content">
            <div class="password-card card">
                <div class="card-content">
                    <div class="list-block">
                        <div class="item-content">
                            <div class="item-title label">原密码</div>
                            <div class="item-input">
                                <input type="password" class="old-psw" placeholder="请输入原密码">
                            </div>
                        </div>
                    </div>
                    <div class="list-block">
                        <div class="item-content">
                            <div class="item-title label">新密码</div>
                            <div class="item-input">
                                <input type="password" class="new-psw" placeholder="请输入新密码">
                            </div>
                        </div>
                    </div>
                    <div class="list-block">
                        <div class="item-content">
                            <div class="item-title label">再次输入</div>
                            <div class="item-input">
                                <input type="password" class="psw-again" placeholder="请再次输入新密码">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class=" saveBtn url" data-url="${basepath}/front/account/toLogin">
                <a class="button button-fill ">保存</a>
            </div>
        </div>
    </div>
</div>
<script type='text/javascript' src='${staticpath}/front/dist/js/lib/zepto.js' charset='utf-8'></script>
<script type='text/javascript' src='${staticpath}/front/dist/js/lib/sm.js' charset='utf-8'></script>
<script type='text/javascript' src='${staticpath}/front/dist/js/lib/sm-extend.js' charset='utf-8'></script>

<script type='text/javascript' >
$('.saveBtn a').click(function(){
    var oldPsw=$('.old-psw').val(),
        newPsw=$('.new-psw').val(),
        pswAgain=$('.psw-again').val();
    if(newPsw==pswAgain){
//        0 志愿者
        if(sessionStorage.role==0){
            $.ajax({
                dataType:'json',
                type:'POST',
                url:'/front/account/updateAccountPwdJson',
                data:{
                    oldPwd:oldPsw,
                    newPwd:newPsw
                },
                success:function(data){
                    if(data.success){
                        $.toast('密码修改成功，请重新登录');
                        setTimeout(function(){
                            var url=$('.url').attr('data-url');
                            window.location.href=url;
                        },2000)
                    }else{
                        $.alert(data.message)
                    }
                }
            })
//            机构修改密码
        }else{
            $.ajax({
                dataType:'json',
                type:'POST',
                url:'/front/account/updateUserJson',
                data:{
                    oldPwd:oldPsw,
                    newPwd:newPsw
                },
                success:function(data){
                    if(data.success){
                        $.toast('密码修改成功，请重新登录');
                        setTimeout(function(){
                            var url=$('.url').attr('data-url');
                            window.location.href=url;
                        },2000)
                    }else{
                        $.alert(data.message)
                    }
                }
            })
        }

    }else{
        $.toast('两次密码不相同，请重新输入')
    }
})
</script>
</body>



</html>
